<template>
  <div>
     <Row>
        <input v-model="gameId" placeholder="游戏id,不填为所有游戏" ></input>
        <input v-model="userId" placeholder="玩家Id" ></input>
        <Button type="primary" @click="onSearch">查询</Button>
    </Row>
    <Table :border="true" :stripe="true" :show-header="true" :height="500" :data="tableData" :columns="tableColumns"></Table>
    <Page class="bottom-page" :total="totalPage" :current="crtPage" :page-size="pageSize" show-total show-elevator @on-change="onChange"></Page>
  </div>
</template>
<script>

import {getJackPotUserJackPots} from '@/api/jackpot.js'
import {getVO} from '@/common/proto-vo.js'
export default {
  data () {
    return {
      tableData: [],
      userId: '',
      gameId: '',
      crtPage: 1,
      totalPage: 0,
      pageSize: 10
    }
  },
  created () {
    this.onSearch()
  },
  methods: {
    onSearch () {
      let tgameId = 0
      if (this.gameId !== '') {
        tgameId = parseInt(this.gameId)
      }
      console.log('this.userId:', this.userId, ',tgameId:', tgameId)
      getJackPotUserJackPots(this.crtPage, this.pageSize, tgameId, this.userId).then((data) => {
        if (!data) {
          return
        }
        this.tableData = []
        let JackPotUserJackPotVO = getVO('JackPotUserJackPotVO')
        let pv = data.data.data
        let len = pv.data.length
        for (let i = 0; i < len; i++) {
          let vo = JackPotUserJackPotVO.decode(pv.data[i])
          vo.jackpotNum = vo.jackpotNum.toFixed(5)
          vo.casinoNum = vo.casinoNum.toFixed(5)
          vo.jackpotNumXL = vo.jackpotNumXL.toFixed(5)
          vo.jackpotNumXXL = vo.jackpotNumXXL.toFixed(5)
          vo.jackpotNumXXXL = vo.jackpotNumXXXL.toFixed(5)

          this.tableData.push(vo)
        }
        this.totalPage = pv.intValues[1]
        console.log(this.tableData)
      })
    },
    onChange (item) {
      console.log(item)
      this.crtPage = item
      this.onSearch()
    }
  },
  computed: {
    tableColumns () {
      let cols = [
        {
          title: '游戏Id',
          key: 'gameId',
          align: 'center'
        },
        {
          title: '玩家Id',
          key: 'userId',
          align: 'center'
        },
        {
          title: 'jackpotNum',
          key: 'jackpotNum',
          align: 'center'
        },
        {
          title: 'casinoNum',
          key: 'casinoNum',
          align: 'center'
        },
        {
          title: 'jackpotNumXL',
          key: 'jackpotNumXL',
          align: 'center'
        },
        {
          title: 'jackpotNumXXL',
          key: 'jackpotNumXXL',
          align: 'center'
        },
        {
          title: 'jackpotNumXXXL',
          key: 'jackpotNumXXXL',
          align: 'center'
        },
        {
          title: '类型',
          key: 'type',
          align: 'center'
        }
      ]
      return cols
    }
  }
}

</script>

<style scoped>
.log-str{
  font-size: 14px;
  margin-bottom: 2px;
}
.content{
  min-height: 460px;
}
.bottom-page{
  margin-top: 5px;
  margin-bottom: 10px;
  float: right;
}
</style>
